$(function(){
	// 显示通知条
	var $noticeBar = $('#notice_bar');
	var timer;
	$.post('notification/marquee', function(data){
		if (!data || !data.data || !data.data.length) return;
		
		var content = '';
		for (var i in data.data) {
			content += '<a data-id="' + data.data[i].id + '" href="javascript:void(0)" class="orange sh">' + data.data[i].subject + '<br /></a>';
		}
		$noticeBar.html(content);
		$noticeBar.find('a').click(function(){
			var id = $(this).attr('data-id');
			myDialog = art.dialog({
				title : "通知详情",
				width : 700,
				padding : "15px 30px 10px 30px",
				lock : true
			});
			$.post("notification/detail", {id : id}, function(data) {
				myDialog.content(data);
			});
		});
		if (data.data.length > 1) {
			timer = marquee();
			$noticeBar.find('a').hover(function(){
				if (timer) clearInterval(timer);
				timer = null;
			}, function(){
				timer = marquee();
			});
		}
	});
	var marquee = function() {
		return setInterval(function(){
			$noticeBar.find('a:first').slideUp(function(){
				$(this).appendTo($noticeBar).show();
			});
		}, 5000);
	}
});